package com.framework.modules.sys.controller;


import com.framework.entity.sys.SysActiveInfo;
import com.framework.exception.util.RespResult;
import com.framework.page.PageUtils;
import com.framework.service.SysActiveInfoService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;


@RestController
@RequestMapping("/sys/sysactiveinfo")
public class SysActiveInfoController extends AbstractController {
    @Autowired
    private SysActiveInfoService sysActiveInfoService ;

    @RequestMapping("/list")
    @RequiresPermissions("sys:sysactive:list")
    public RespResult list(@RequestParam Map<String,Object> params){

        PageUtils page = sysActiveInfoService.queryActiveList(params);
        return RespResult.ok().put("page",page);
    }
    @RequestMapping("/add")
    @RequiresPermissions("sys:sysactive:add")
    public RespResult add(@RequestBody SysActiveInfo sysActiveInfo){
        sysActiveInfoService.insertActiveInfo(sysActiveInfo);
        return RespResult.ok();
    }

    @RequestMapping("/findInfoById")
    public RespResult findById(@RequestParam Long activeInfoId){
        SysActiveInfo sysAvtiveInfo=sysActiveInfoService.queryActiveInfoById(activeInfoId);
        return RespResult.ok().put("activeInfo",sysAvtiveInfo);

    }
    @RequestMapping("/update")
    @RequiresPermissions("sys:sysactive:update")
    public RespResult updateById(@RequestBody SysActiveInfo sysActiveInfo ){
        sysActiveInfoService.updateActiveById(sysActiveInfo);
        return RespResult.ok();
    }

    @RequestMapping("/deleteById")
    public RespResult deleteById(@RequestParam Long activeInfoId){
        sysActiveInfoService.deleteActiveInfoById(activeInfoId);
        return RespResult.ok();
    }
}
